#include "LinkStack.h"
#include <stdio.h>
#define true 1
#define false 0

int InitLinkstack(LinkStack *s)
{
    return InitDLinkList(&s->stack);
}

Node *GetTop(LinkStack *s)
{
    return s->stack.tail;
}

void Push(LinkStack *s, ElementType element)
{
    InsertTail(&s->stack,element);
}

ElementType *Pop(LinkStack *s)
{
    if(s->stack.tail==NULL)
    {
        return NULL;
    }
    s->TopData=s->stack.tail->data;
    RemoveByIndex(&s->stack,s->stack.len-1);
    return &s->TopData;
}

int IsEmpty(LinkStack *s)
{
    if(s->stack.len==0)
        return true;
    else
        return false;
}

void FreeStack(LinkStack *s)
{
    FreeDLinkList(&s->stack);
}
